using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;

namespace XNALibrary.PostProcessing
{
    public class BaseFilter
    {
        private RenderTarget2D renderTarget;
        private Effect shader;
        private int texture;
        private PostProcessingManager owner;

        #region Properties
        public PostProcessingManager Owner
        {
            get { return owner; }
            set { owner = value; }
        }
        public RenderTarget2D RenderTarget
        {
            get { return renderTarget; }
            set { renderTarget = value; }
        }

        public Effect Shader
        {
            get { return shader; }
            set { shader = value; }
        }

        public int Texture
        {
            get { return texture; }
            set { texture = value; }
        }
        #endregion

        //Constructor
        public BaseFilter(int texture) 
        {
            Texture = texture;
        }

        //Inicializador
        public virtual void Register() { }

        public virtual void Update() { }

        public virtual void DrawFilter(Texture2D texture, Effect effect, SpriteBatch sprite)
        {
            effect.Begin();
            sprite.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.SaveState);

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                sprite.Draw(texture, Vector2.Zero, Color.White);
                pass.End();
            }

            sprite.End();
            effect.End();
        }
    }
}
